Skip to content

LCORE-1329: Adding new MCP E2E Tests#1294

Closed
jrobertboos wants to merge 101 commits intolightspeed-core:mainfrom
jrobertboos:lcore-1329
Closed

LCORE-1329: Adding new MCP E2E Tests#1294
jrobertboos wants to merge 101 commits intolightspeed-core:mainfrom
jrobertboos:lcore-1329

Conversation

@jrobertboos
Copy link
Contributor

@jrobertboos jrobertboos commented Mar 9, 2026

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: (e.g., Claude, CodeRabbit, Ollama, etc., N/A if not used)
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Tests

    • Expanded end-to-end MCP auth coverage (file, Kubernetes, client, OAuth) with success/error scenarios, new test annotations, and additional negative assertions.
    • Removed a legacy file-based MCP feature from the active test list.
  • Chores

    • Added new test configurations and an invalid-token for auth error scenarios.
    • Improved test environment management to clear persistent test data and unregister external toolgroups between scenarios.
  • Documentation

    • Updated end-to-end testing docs to reflect utility renaming and behavior.

…ent, and llama-stack-api; add new package 'circuitbreaker' version 2.1.3 and 'oci' version 2.168.0; adjust supported Llama Stack version in constants; fix response handling in utils.
- Introduced new YAML configuration files for MCP authentication methods: file, Kubernetes, and OAuth.
- Updated existing MCP configuration to include new authentication methods.
- Enhanced end-to-end tests to cover scenarios for file-based, Kubernetes, and OAuth authentication.
- Added utility functions for unregistering MCP toolgroups in the testing environment.
- Implemented new step definitions for checking response body content in tests.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds end-to-end MCP authentication support and tests: new library/server-mode MCP configs (file, invalid-file, client, kubernetes, oauth), expanded mcp.feature tests, test environment wiring, utilities to unregister MCP toolgroups and clear Llama Stack storage, a secret file, and a docker volume mount for the invalid token.

Changes

Cohort / File(s) Summary
Docker configuration
docker-compose.yaml
Added a volume mount exposing host secret to /tmp/invalid-mcp-secret-token in the lightspeed-stack service.
Library-mode configs
tests/e2e/configuration/library-mode/...
tests/e2e/configuration/library-mode/lightspeed-stack-mcp.yaml, ...-mcp-file-auth.yaml, ...-mcp-client-auth.yaml, ...-mcp-kubernetes-auth.yaml, ...-mcp-oauth-auth.yaml, ...-invalid-mcp-file-auth.yaml
Added multiple library-mode YAMLs for MCP auth variants and an invalid-token variant; updated MCP server list (removed provider_id, added mcp-kubernetes/mcp-file/mcp-client entries and adjusted authorization header paths).
Server-mode configs
tests/e2e/configuration/server-mode/...
tests/e2e/configuration/server-mode/lightspeed-stack-mcp.yaml, ...-mcp-file-auth.yaml, ...-mcp-client-auth.yaml, ...-mcp-kubernetes-auth.yaml, ...-mcp-oauth-auth.yaml, ...-invalid-mcp-file-auth.yaml
Added server-mode YAMLs for MCP auth variants and invalid-token variant; updated MCP server list (removed provider_id, added additional MCP server entries with distinct Authorization values).
E2E feature tests
tests/e2e/features/mcp.feature
Large expansion to cover file, kubernetes, client, and oauth auth schemes across tools/query/streaming_query, including success and invalid-token (401) paths and new scenario tags for config selection.
Removed feature
tests/e2e/features/mcp_file_auth.feature
Removed deprecated standalone MCP file-auth feature and its test-list entry from tests/e2e/test_list.txt.
Test environment & steps
tests/e2e/features/environment.py, tests/e2e/features/steps/common_http.py
Environment: added MCP config mappings, tag-based config resolution, calls to unregister_mcp_toolgroups or clear_llama_stack_storage when switching configs, and extended after hooks; Steps: added check_response_body_does_not_contain.
Llama Stack test utilities
tests/e2e/utils/llama_stack_utils.py
Added async helpers to list/unregister MCP toolgroups and a public sync wrapper unregister_mcp_toolgroups(); improved error handling and ensured client cleanup.
General test utilities
tests/e2e/utils/utils.py
Added clear_llama_stack_storage() to remove ~/.llama inside the lightspeed-stack container (no-op in Prow), with timeout handling.
Secrets & docs
tests/e2e/secrets/invalid-mcp-token, docs/e2e_testing.md
Added invalid-mcp-token containing invalid-token; updated docs to reflect rename to llama_stack_utils.py.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant TestRunner as Test Runner
participant LCS as lightspeed-stack (service)
participant Llama as llama-stack
participant MCP as mock-mcp
rect rgba(200,220,255,0.5)
TestRunner->>LCS: start/apply config (mcp auth variant)
TestRunner->>LCS: send request (tool/query/streaming_query)
LCS->>Llama: forward request (library/client mode) or use internal tool
LCS->>MCP: call MCP endpoint with Authorization header
MCP-->>LCS: 200 / 401 response
LCS-->>TestRunner: return result (assertions)
end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'LCORE-1329: Adding new MCP E2E Tests' directly and clearly describes the main change—adding new end-to-end tests for MCP (Model Context Protocol) authentication scenarios across multiple test configuration files and feature tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

jrobertboos and others added 27 commits March 9, 2026 16:22
- Added a new invalid MCP token file for testing purposes.
- Updated the Docker Compose configuration to mount the invalid MCP token.
- Introduced a new YAML configuration for testing invalid MCP file authentication.
- Enhanced the test scenarios to include checks for invalid MCP file authentication.
- Updated feature files to reflect the new authentication configurations.
…d-dependencies

LCORE-1326: Updated dependencies
…d-konflux-dependencies

LCORE-1326: Updated Konflux dependencies
…moveprefix-method

LCORE-1438: Use removeprefix method
…inter-rule

LCORE-1437: Enable linter rule B010
…all-commands-during-konflux-requirements-generation

LCORE-1439: print all commands during Konflux requirements generation
…ent script

Update rag_guide.md to recommend `uv run` instead of `python` for running  `llama_stack_configuration.py`, otherwise the dependency on `azure` will not be loaded.
recommend `uv run` instead of `python` in `rag_guide.md`
…-string-format

LCORE-1438: better string format
…handling

- Added new configurations for invalid, Kubernetes, client, and OAuth MCP authentication methods.
- Updated scenario handling to reference the new configuration paths for Kubernetes, client, and OAuth authentication.
- Enhanced the testing environment to support the new authentication configurations.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2026

Summary

  • Single-line addition to tests/e2e/features/mcp.feature leveraging an existing step definition
  • No new code or step definitions required; the does not contain assertion is already implemented and actively used elsewhere in the file
🤖 Prompt for AI Agents
Add a single missing assertion line to the MCP E2E test feature file to verify
the `mcp-client` tool is not invoked when the client-provided auth token is
omitted.

- In `tests/e2e/features/mcp.feature`, add the following line at approximately
line 224 (as indicated by the PR review comment):
  `And The body of the response does not contain mcp-client`
- The step definition for this assertion already exists in
`tests/e2e/features/steps/common_http.py` (lines 175-181) — **do not modify that
file**
- Place the new assertion consistently with how similar scenarios in the file
use this pattern (e.g., reference the streaming_query scenario at lines 227-241
for placement style)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
tests/e2e/features/mcp.feature (1)

10-10: ⚠️ Potential issue | 🟠 Major

Blanket @skip tags still hide core MCP auth regressions.

At Line [10], Line [49], Line [65], Line [84], Line [104], Line [146], Line [163], Line [183], and Line [204], unconditional skips disable the exact /tools and invalid-token paths this PR is meant to validate. Prefer targeted mode-specific skipping (@skip-in-library-mode) where applicable so non-library runs still exercise these regressions.

Also applies to: 49-49, 65-65, 84-84, 104-104, 146-146, 163-163, 183-183, 204-204

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/features/mcp.feature` at line 10, Replace the blanket `@skip` tag
used across the MCP feature scenarios with targeted mode-specific skips so
non-library test runs still execute the important auth paths: locate every
occurrence of the '@skip' tag in the MCP feature (the scenarios covering the
/tools endpoint and invalid-token flows) and change them to
'@skip-in-library-mode' where the test truly should only be skipped in library
mode; leave any scenarios that must never run in any mode as explicit skips but
prefer the '@skip-in-library-mode' tag for the cases called out (the /tools and
invalid-token scenarios) so non-library CI will exercise those regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/e2e/features/mcp.feature`:
- Line 10: Replace the blanket `@skip` tag used across the MCP feature scenarios
with targeted mode-specific skips so non-library test runs still execute the
important auth paths: locate every occurrence of the '@skip' tag in the MCP
feature (the scenarios covering the /tools endpoint and invalid-token flows) and
change them to '@skip-in-library-mode' where the test truly should only be
skipped in library mode; leave any scenarios that must never run in any mode as
explicit skips but prefer the '@skip-in-library-mode' tag for the cases called
out (the /tools and invalid-token scenarios) so non-library CI will exercise
those regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9fd6b71c-0675-48de-bb0d-2068adb8d55d

📥 Commits

Reviewing files that changed from the base of the PR and between eac693d and d4f4518.

📒 Files selected for processing (1)
  • tests/e2e/features/mcp.feature

- Introduced new YAML configuration files for MCP authentication methods: file, Kubernetes, and OAuth.
- Updated existing MCP configuration to include new authentication methods.
- Enhanced end-to-end tests to cover scenarios for file-based, Kubernetes, and OAuth authentication.
- Added utility functions for unregistering MCP toolgroups in the testing environment.
- Implemented new step definitions for checking response body content in tests.
- Added a new invalid MCP token file for testing purposes.
- Updated the Docker Compose configuration to mount the invalid MCP token.
- Introduced a new YAML configuration for testing invalid MCP file authentication.
- Enhanced the test scenarios to include checks for invalid MCP file authentication.
- Updated feature files to reflect the new authentication configurations.
…handling

- Added new configurations for invalid, Kubernetes, client, and OAuth MCP authentication methods.
- Updated scenario handling to reference the new configuration paths for Kubernetes, client, and OAuth authentication.
- Enhanced the testing environment to support the new authentication configurations.
- Renamed `llama_stack_shields.py` to `llama_stack_utils.py` and expanded its functionality to manage both toolgroups and shields.
- Removed the deprecated `llama_stack_tools.py` file.
- Updated E2E test scenarios to utilize the new utility functions for unregistering toolgroups and clearing Llama Stack storage.
- Enhanced feature files to include comments indicating pending fixes for skipped scenarios.
- Added checks to ensure the response body does not contain 'mcp-client' in MCP feature tests.
- Simplified the `clear_llama_stack_storage` function to remove the entire `~/.llama` directory instead of specific files, improving clarity and efficiency.
- Updated comments to reflect the changes in storage clearing logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants